﻿Imports CrystalClientManagement.BLL
Imports Crystal.CLL

Public Class frmDeleteClient
#Region "Declare"
    Public clientID As String = String.Empty
    Public IsClientDeleted As Boolean = False
#End Region

#Region "Properties"
    Public Property Client() As String
        Get
            Return clientID
        End Get
        Set(ByVal value As String)
            clientID = value
        End Set
    End Property

    Public Property ClientDeleted() As Boolean
        Get
            Return IsClientDeleted
        End Get
        Set(ByVal value As Boolean)
            IsClientDeleted = value
        End Set
    End Property
#End Region

#Region "From Load"
    Private Sub frmDeleteClient_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Client <> String.Empty Then
            DisableButtons()
            Dim data As DataSet = DeleteClient.GetDeleteStatus(Client)
            If data IsNot Nothing Then
                If data.Tables(0).Rows.Count > 0 Then
                    For i As Integer = 0 To data.Tables(0).Rows.Count - 1
                        If data.Tables(0).Rows(i)("Status") = ProjectStatus.DRPND Then
                            lblDRPending.Visible = True
                            lnkYesBtnReqPending.Visible = True
                            lnkNoBtnReqPending.Visible = True
                            lbl1.Visible = True
                        ElseIf data.Tables(0).Rows(i)("Status") = ProjectStatus.DESRT Then
                            lblDEStarted.Visible = True
                            lnkYesBtnDEStarted.Visible = True
                            lnkNoBtnDEStarted.Visible = True
                            lbl3.Visible = True
                        ElseIf data.Tables(0).Rows(i)("Status") = ProjectStatus.FNLST Then
                            lblListFinal.Visible = True
                            lnkYesBtnListFinal.Visible = True
                            lnkNoBtnListFinal.Visible = True
                            lbl4.Visible = True
                        ElseIf data.Tables(0).Rows(i)("Status") = ProjectStatus.DRSNT Then
                            lblDRSent.Visible = True
                            lnkYesBtnReqSent.Visible = True
                            lnkNoBtnReqSent.Visible = True
                            lbl2.Visible = True
                        End If
                    Next
                End If

            End If
        End If
    End Sub
    Private Sub DisableButtons()
        lblDRPending.Visible = False
        lnkYesBtnReqPending.Visible = False
        lnkNoBtnReqPending.Visible = False
        lblDRSent.Visible = False
        lnkYesBtnDEStarted.Visible = False
        lnkNoBtnDEStarted.Visible = False
        lblListFinal.Visible = False
        lnkYesBtnListFinal.Visible = False
        lnkNoBtnListFinal.Visible = False
        lblDEStarted.Visible = False
        lnkYesBtnReqSent.Visible = False
        lnkNoBtnReqSent.Visible = False
        lbl1.Visible = False
        lbl2.Visible = False
        lbl3.Visible = False
        lbl4.Visible = False
    End Sub
    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        If Not DeleteClient.IsClientDeleted(Client) Then
            Me.Close()
        Else
            IsClientDeleted = True
            MessageBox.Show("Client deleted successfully.", BaseClass.crystalCaption, MessageBoxButtons.OK, MessageBoxIcon.Information)
            Me.Close()
        End If
    End Sub
#End Region

#Region "Events"

    Private Sub lnkYesBtnReqPending_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lnkYesBtnReqPending.LinkClicked
        DeleteClient.DeleteProjectClients(Client, ProjectStatus.DRPND.ToString)
        lblRequestPending.Text = "Project deleted."
        'lnkYesBtnReqPending.Enabled = False
        'lnkNoBtnReqPending.Enabled = False
    End Sub
    Private Sub lnkYesBtnDEStarted_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkYesBtnDEStarted.Click
        DeleteClient.DeleteProjectClients(Client, ProjectStatus.DESRT.ToString)
        lblDECancelled.Text = "Project marked as Cancelled."
        'lnkYesBtnDEStarted.Enabled = False
        'lnkNoBtnDEStarted.Enabled = False
    End Sub

    Private Sub lnkYesBtnListFinal_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkYesBtnListFinal.Click
        DeleteClient.DeleteProjectClients(Client, ProjectStatus.FNLST.ToString)
        lblListCancelled.Text = "Project marked as Cancelled."
        'lnkYesBtnListFinal.Enabled = False
        'lnkNoBtnListFinal.Enabled = False
    End Sub

    Private Sub lnkYesBtnReqSent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkYesBtnReqSent.Click
        DeleteClient.DeleteProjectClients(Client, ProjectStatus.DRSNT.ToString)
        lblRequestSent.Text = "Project deleted."
        'lnkYesBtnReqSent.Enabled = False
        'lnkNoBtnReqSent.Enabled = False
    End Sub
    Private Sub lnkNoBtnReqPending_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNoBtnReqPending.Click
        lblRequestPending.Text = "Project not deleted."
        'lnkYesBtnReqPending.Enabled = False
        'lnkNoBtnReqPending.Enabled = False
    End Sub

    Private Sub lnkNoBtnDEStarted_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNoBtnDEStarted.Click
        lblDECancelled.Text = "Project not marked as Cancelled."
        'lnkYesBtnDEStarted.Enabled = False
        'lnkNoBtnDEStarted.Enabled = False
    End Sub

    Private Sub lnkNoBtnListFinal_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNoBtnListFinal.Click
        lblListCancelled.Text = "Project not marked as Cancelled."
        'lnkYesBtnListFinal.Enabled = False
        'lnkNoBtnListFinal.Enabled = False
    End Sub

    Private Sub lnkNoBtnReqSent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkNoBtnReqSent.Click
        lblRequestSent.Text = "Project not deleted."
        'lnkYesBtnReqSent.Enabled = False
        'lnkNoBtnReqSent.Enabled = False
    End Sub

#End Region


End Class